/*
 * Copyright (c) Liu Wei <liuw.name@gmail.com>
 * All rights reserved.
 *
 * This file is part of the RabbitOS.  The RabbitOS is free software, also known
 * as "open source;" you can redistribute it and/or modify it under the terms
 * of the GNU General Public License (GPL), version 2, as published by the Free
 * Software Foundation (FSF).  To explore alternate licensing terms, contact
 * the Rabbit OS team.
 * 
 * The RabbitOS is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GPL for more details.  You should have
 * received a copy of the GPL along with the RabbitOS; see the file COPYING. If
 * not, write to the FSF, 59 Temple Place #330, Boston, MA 02111-1307, USA.
 *
 */
/*
 * Declarations of IO operations.
 * Original C version by Tan Menglong
 * New ASM version by liuw
 * 30-Mar-08
 */

#ifndef _RABBIT_IO_H
#define _RABBIT_IO_H

#define outb(port, value) \
	asm volatile ("outb %%al, %%dx"::"a" (value), "d" (port))

#define inb(port) ({ \
	unsigned char __res; \
	asm volatile ("inb %%dx, %%al":"=a" (__res): "d" (port)); \
	__res; \
})


/* this will wait for a moment */
#define inb_p(port) ({ \
	unsigned char __res; \
	asm volatile ("inb %%dx, %%al\n" \
		"\tjmp 1f\n" \
		"1:\tjmp 1f\n" \
		"1:":"=a" (__res): "d" (port)); \
	__res; \
})


#endif							//_RABBIT_IO_H
